package learn.recursion;

/**
 * @author baoshi
 */
public class RecursionDemo {
    public static void main(String[] args) {
        System.out.println(factorial(0));
    }

    public static void test(int n) {
        if (n > 2) {
            test(n - 1);
        } else {
            System.out.println("n = " + n);
        }
    }

    public static int factorial(int n) {
        if (n<=0) return 0;
        if (n == 1) {
            return 1;
        } else {
            return factorial(n - 1) * n; // 返回 (n-1)! * n -> n!
        }
    }
}
